package cn.itcast.service;

import cn.itcast.repository.MetaDatabaseRepository;
import cn.itcast.domain.MetaDatabase;
import cn.itcast.utils.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

/**
 * create by zhangtian on 2019/1/11
 */
@Service
public class MetaDatabaseService {
    @Autowired
    private MetaDatabaseRepository metaDatabaseRepository ;

    /**
     * 保存数据库元信息
     * @param metaDatabase
     * @return
     */
    @Transactional
    public ServerResponse<MetaDatabase> saveMetaDatabase(MetaDatabase metaDatabase) {
        return ServerResponse.createBySuccess(metaDatabaseRepository.save(metaDatabase)) ;
    }

    /**
     * 查询所有的数据库元信息
     * @return
     */
    public ServerResponse<Iterable<MetaDatabase>> findAllMetaDatabase() {
        return ServerResponse.createBySuccess(metaDatabaseRepository.findAll()) ;
    }
}
